package com.lmt.org.service.impl;

import com.lmt.basic.utils.PageList;
import com.lmt.org.domain.Employee;
import com.lmt.org.mapper.EmployeeMapper;
import com.lmt.org.query.EmployeeQuery;
import com.lmt.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @Description: TODO
* @Author: Amazing
* @Version: 1.0
* @Date:  2022/6/21 18:20
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public List<Employee> loadAll() {
        return employeeMapper.loadAll();
    }

    @Override
    public Employee loadById(Long id) {
        return employeeMapper.loadById(id);
    }

    @Override
    @Transactional
    public void remove(Long id) {
        employeeMapper.remove(id);
    }

    @Override
    @Transactional
    public void save(Employee employee) {
        employeeMapper.save(employee);
    }

    @Override
    @Transactional
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    public PageList<Employee> queryData(EmployeeQuery employeeQuery) {
        List<Employee> rows = employeeMapper.queryData(employeeQuery);
        Integer total = employeeMapper.queryCount(employeeQuery);
        return new PageList<>(total, rows);
    }

    @Override
    public Integer queryCount(EmployeeQuery employeeQuery) {
        return employeeMapper.queryCount(employeeQuery);
    }

    @Override
    public void batch(Long[] ids) {
        employeeMapper.batch(ids);
    }
}
